<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试工具 - 颜色生成器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }
        .container {
            background: white;
            border-radius: 10px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
        }
        .color-generator {
            text-align: center;
        }
        .color-display {
            width: 200px;
            height: 200px;
            margin: 20px auto;
            border-radius: 10px;
            border: 3px solid #ddd;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            font-weight: bold;
            color: white;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        }
        button {
            background: #667eea;
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            margin: 10px;
            transition: background 0.3s;
        }
        button:hover {
            background: #5a6fd8;
        }
        .color-info {
            margin-top: 20px;
            padding: 15px;
            background: #f8f9fa;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎨 随机颜色生成器</h1>
        <div class="color-generator">
            <div class="color-display" id="colorDisplay">
                点击生成颜色
            </div>
            <button onclick="generateColor()">生成随机颜色</button>
            <button onclick="copyColor()">复制颜色代码</button>
            <div class="color-info">
                <p><strong>颜色代码:</strong> <span id="colorCode">#000000</span></p>
                <p><strong>RGB:</strong> <span id="rgbCode">rgb(0, 0, 0)</span></p>
            </div>
        </div>
    </div>

    <script>
        let currentColor = '#000000';

        function generateColor() {
            // 生成随机颜色
            const r = Math.floor(Math.random() * 256);
            const g = Math.floor(Math.random() * 256);
            const b = Math.floor(Math.random() * 256);
            
            currentColor = '#' + [r, g, b].map(x => {
                const hex = x.toString(16);
                return hex.length === 1 ? '0' + hex : hex;
            }).join('');
            
            const rgbColor = `rgb(${r}, ${g}, ${b})`;
            
            // 更新显示
            const display = document.getElementById('colorDisplay');
            display.style.backgroundColor = currentColor;
            display.textContent = currentColor;
            
            document.getElementById('colorCode').textContent = currentColor;
            document.getElementById('rgbCode').textContent = rgbColor;
        }

        function copyColor() {
            navigator.clipboard.writeText(currentColor).then(() => {
                alert('颜色代码已复制到剪贴板！');
            }).catch(() => {
                // 备用方案
                const textArea = document.createElement('textarea');
                textArea.value = currentColor;
                document.body.appendChild(textArea);
                textArea.select();
                document.execCommand('copy');
                document.body.removeChild(textArea);
                alert('颜色代码已复制到剪贴板！');
            });
        }

        // 初始化
        generateColor();
    </script>
</body>
</html>